{% extends 'blog/i/base.html' %}

{% block selfstyle %}

<link rel="stylesheet" href="{{ STATIC_URL }}js/ueditor/themes/default/ueditor.css"/>
  <style type='text/css'>

   .error{
      line-height:18px;
      height:28px;
      color: #d21a00;
      padding:10px 0px;
      padding-left:15px;
      float: left;
   }

  </style>
{% endblock %}


{% block ihome %}

<div class="current_location" >
  <h3><a  href="/blog" class="cl" >日记</a></h3><span>>></span><span>编辑日记</span><a href="{{ user_url }}/blog" class="cr" >我的日记</a>
</div>

{% endblock %}



{% block content %}

               <form action="/blog/save" method="post" >
      			    <div class="new_article" >
                    
                        {{ form.id }}
                        <p>
                            <label for="title" >题目</label><br/>
                           {{ form.title }}
                              <span class='error' >{% for error in form.title.errors  %}  {{ error }} {% endfor %} </span>
                        </p>
                        <p style='margin:0px' >
                           <span style='font-size:12px;color:#333' > 文章创建于：{{ time|date:'Y-m-d H:i' }} </span>
                        </p>
                        <p>
                            <label for="content" >正文</label><br/>
                            {{ form.content }} 
                        </p>
                        <p >
                            <input type="submit" class="action"  value="保存" />
                            <a class='cancel'  href="{{ user_url }}/blog">取消</a>
                        </p>
                    
                </div>
                <div class="wrap_subject" >
                  <div class="sj">
                    <h3>选择主题：</h3>
                    <ul>
                      {% for s in subjects %}

                        <li><a class="subject" id="{{ s.id }}" href="javascript:void(0)">{{ s.subject }}</a></li>

                      {% endfor %}
                      
                    </ul>
                  </div>
                  <div class="tg" >
                      <label for="tag" class="sl" >选择标签:</label>
                      <ul class="holder" >
                          {% for t in tag_list %}
                              <li id="pt_1" class="bit_box">
                                <span></span>
                                <label>{{ t.tag }}</label>
                                <input type="hidden" name="tag_list" value="{{ t.id }}">
                              </li>
                          {% endfor %}
                      </ul>
                      <input type="text" id="tag" name="tagtext" autocomplete="off" class="text"  >
                  </div>
                </div>
                </form>
{% endblock %}



{% block selfscript %}



<script type="text/javascript" src="{{ STATIC_URL }}js/ueditor/editor_config.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}js/ueditor/editor_all.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}js/complete.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}js/blog.js"></script>


<script type="text/javascript">

var editor=null;
$(document).ready(function(){
       editor = new baidu.editor.ui.Editor({ 
                    autoFloatEnabled:true,
                    textarea : 'editorValue',
                    initialStyle: 'body{font-size: 14px; font-family:Arial,Helvetica,sans-serif;font-weight:normal;color:#333333 !important}'
                });
      editor.render("content");

     function add_tag(id,tag){
        var input = $('<input type="hidden" name="tag_list"/>').attr('value',id);
        var label = $('<label></label>').prepend(tag);
        var span = $('<span></span>');
        var li = $('<li class="bit_box"  id="pt_'+id+'"></li>').prepend(span).append(label).append(input);

        $(".holder").append(li)
      }

      function add_subject(id){
        var input = $('<input type="hidden" name="subject_list"/>').attr('value',id);
        $("form").append(input);
        $("a[id='"+id+"']").addClass("shighelight");
      }


      {% if subject_list %}

          {% for s in subject_list %}
              add_subject({{ s.id }})
          {% endfor %}

      {% endif %}
});

</script>

{% endblock %}



